import request from "@/utils/request";

const RECHARGE_BASE_URL = "/recharge";
const PAY_BASE_URL = "/pay";
const CONNSUME_BASE_URL = "/consumption";
const TRADE_BASE_URL = "/commission";
const WITHDRAWAL_BASE_URL = "/withdrawal";
const VIP_BASE_URL = "/vip";
const BALANCE_BASE_URL = "/balance";

class TradeAPI {
  /**
   * 会员详情
   *
   * @param id 查询参数
   */
  static getVipInfo(params: any) {
    return request<any>({
      url: `${VIP_BASE_URL}/detail`,
      method: "get",
      params,
    });
  }
  /**
   * 会员记录审核
   *
   * @param queryParams 查询参数
   */
  static getVipAudit(data: any) {
    return request<any>({
      url: `${VIP_BASE_URL}/audit`,
      method: "post",
      data: data,
    });
  }

  /**
   * 会员记录分页列表
   *
   * @param queryParams 查询参数
   */
  static getVipPage(queryParams: UserPageQuery) {
    return request<any, PageResult<UserPageVO[]>>({
      url: `${VIP_BASE_URL}/page`,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 返佣审核
   *
   * @param id 查询参数
   */
  static getWithdrawalAudit(data: any) {
    return request<any>({
      url: `${WITHDRAWAL_BASE_URL}/audit`,
      method: "post",
      data,
    });
  }

  /**
   * 返佣详情
   *
   * @param id 查询参数
   */
  static getWithdrawalInfo(params: any) {
    return request<any>({
      url: `${WITHDRAWAL_BASE_URL}/detail`,
      method: "get",
      params,
    });
  }

  /**
   * 收益记录批量删除，多个以英文逗号(,)分割
   *
   * @param ids 用户ID字符串，多个以英文逗号(,)分割
   */
  static deleteWithdrawalIds(data: any) {
    return request({
      url: `${WITHDRAWAL_BASE_URL}/del`,
      method: "post",
      data: data,
    });
  }
  /**
   * 收益记录分页列表
   *
   * @param queryParams 查询参数
   */
  static getWithdrawalPage(queryParams: UserPageQuery) {
    return request<any, PageResult<UserPageVO[]>>({
      url: `${WITHDRAWAL_BASE_URL}/page`,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 返佣审核
   *
   * @param id 查询参数
   */
  static getTradeAudit(data: any) {
    return request<any>({
      url: `${TRADE_BASE_URL}/audit`,
      method: "post",
      data,
    });
  }

  /**
   * 返佣详情
   *
   * @param id 查询参数
   */
  static getTradeInfo(params: any) {
    return request<any>({
      url: `${TRADE_BASE_URL}/detail`,
      method: "get",
      params,
    });
  }

  /**
   * 返佣记录批量删除，多个以英文逗号(,)分割
   *
   * @param ids 用户ID字符串，多个以英文逗号(,)分割
   */
  static deleteTradeIds(data: any) {
    return request({
      url: `${TRADE_BASE_URL}/del`,
      method: "post",
      data: data,
    });
  }
  /**
   * 返佣记录分页列表
   *
   * @param queryParams 查询参数
   */
  static getTradePage(queryParams: UserPageQuery) {
    return request<any, PageResult<UserPageVO[]>>({
      url: `${TRADE_BASE_URL}/page`,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 获取消费记录分页列表
   *
   * @param queryParams 查询参数
   */
  static getConsumPage(queryParams: UserPageQuery) {
    return request<any, PageResult<UserPageVO[]>>({
      url: `${CONNSUME_BASE_URL}/page`,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 获取对账分页列表
   *
   * @param queryParams 查询参数
   */
  static getRechargePage(queryParams: UserPageQuery) {
    return request<any, PageResult<UserPageVO[]>>({
      url: `${RECHARGE_BASE_URL}/page`,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 对账审核
   *
   * @param ids 用户ID数组
   */
  static setRechargeAudit(data: any) {
    return request({
      url: `${RECHARGE_BASE_URL}/audit`,
      method: "post",
      data: data,
    });
  }

  /**
   * 微信退款
   *
   * @param queryParams 查询参数
   */
  static getPayRefund(data: any) {
    return request<any>({
      url: `${PAY_BASE_URL}/refund`,
      method: "post",
      data,
    });
  }

  /**
   * 获取微信分页列表
   *
   * @param queryParams 查询参数
   */
  static getPayPage(queryParams: UserPageQuery) {
    return request<any, PageResult<UserPageVO[]>>({
      url: `${PAY_BASE_URL}/page`,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 获取余额提现列表
   *
   * @param queryParams 查询参数
   */
  static getBalancePage(queryParams: UserPageQuery) {
    return request<any, PageResult<UserPageVO[]>>({
      url: `${BALANCE_BASE_URL}/page`,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 获取余额记录详情
   *
   * @param params 查询参数
   */
  static getBalanceDetail(params: any) {
    return request<any>({
      url: `${BALANCE_BASE_URL}/detail`,
      method: "get",
      params,
    });
  }

  /**
   * 提现记录审核
   *
   * @param queryParams 查询参数
   */
  static balanceAudit(data: any) {
    return request<any>({
      url: `${BALANCE_BASE_URL}/audit`,
      method: "post",
      data: data,
    });
  }
}

export default TradeAPI;

/**
 * 用户分页查询对象
 */
export interface UserPageQuery extends PageQuery {
  /** 搜索关键字 */
  keywords?: string;

  /** 客户状态 */
  status?: number;

  /** 是否会员 */
  is_vip?: number;

  createTime?: any;

  /** 开始时间 */
  startDate?: string | number | null;

  /** 结束时间 */
  endDate?: string | number | null;

  is_type?: number;

  is_add?: number;

  is_show?: number;
}

/** 分页对象 */
export interface UserPageVO {
  /** 用户名 */
  name?: string;
  /** 手机号码 */
  tel?: string;
  /** 标题 */
  title?: string;
  /** ID */
  id?: number;
  /** 管理员备注 */
  admin_msg?: string;
  /** 描述 */
  othor?: string;
}
